import { SEntityId } from "../../../../Message/Public/SEntityId";
import { IEntity } from "../../scene/player/IEntity";
import { GTextFormat } from "../../../common/GTextFormat";
import { GameDefConfig } from "../../resource/GameDefConfig";
import { ColorConfig } from "../../resource/ColorConfig";
type int = number;
//class SearchPlayerItem
    
    export  class SearchPlayerItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            mouseChildren = false;
            return;
        }

        public get entity(): SEntityId
        {
            if (this._entity == null) 
            {
                return null;
            }
            return this._entity.entityInfo.entityInfo.entityId;
        }

        public get playerInfo(): IEntity
        {
            if (this._entity == null) 
            {
                return null;
            }
            return this._entity;
        }

        public get isDraw(): Boolean
        {
            return this._isDraw;
        }

        /* internal  */init(): void
        {
            this._txtTf = new GTextFormat("", 12, 11661311, null, null, null, null, null, flash.text.TextFormatAlign.CENTER);
            this._nameTxt = this.createTextField(0, 0, 120, 23, "", this._txtTf);
            this._levelTxt = this.createTextField(105, 0, 60, 23, "99", this._txtTf);
            this._campTxt = this.createTextField(160, 0, 90, 23, "", this._txtTf);
            this.graphics.moveTo(0, 23);
            this.graphics.lineStyle(0.8, 282466);
            this.graphics.lineTo(255, 23);
            this._shape = new Object /* flash.display.Shape */();
            this._shape.x = 0;
            this._shape.y = 0;
            addChildAt(this._shape, 0);
            return;
        }

        /* internal  */createTextField(arg1: int, arg2: int, arg3: int, arg4: int, arg5: string, arg6: Object /* flash.text.TextFormat */): Object /* flash.text.TextField */
        {
            var loc1;
            (loc1 = new Object /* flash.text.TextField */()).selectable = false;
            loc1.x = arg1;
            loc1.y = arg2;
            loc1.width = arg3;
            loc1.height = arg4;
            loc1.htmlText = arg5;
            loc1.setTextFormat(arg6);
            addChild(loc1);
            return loc1;
        }

        public updateData(arg1: IEntity): void
        {
            if (arg1 == null) 
            {
                this._nameTxt.text = "";
                this._levelTxt.text = "";
                this._campTxt.text = "";
                this._entity = null;
                return;
            }
            this._entity = arg1;
            this._nameTxt.text = arg1.entityInfo.entityInfo.name.toString();
            this._nameTxt.setTextFormat(this._txtTf);
            this._levelTxt.text = arg1.entityInfo.entityInfo.level.toString();
            this._levelTxt.setTextFormat(this._txtTf);
            var loc1=arg1.entityInfo.entityInfo.camp;
            this._campTxt.text = GameDefConfig.instance.getECamp(loc1);
            var loc2=ColorConfig.instance.getCountryColor(loc1).intColor;
            var loc3=new GTextFormat("", 12, loc2, false, false, false, null, null, flash.text.TextFormatAlign.CENTER);
            this._campTxt.setTextFormat(loc3);
            return;
        }

        public drawGrayColor(): void
        {
            if (this._entity != null) 
            {
                this._isDraw = true;
                this._shape.graphics.clear();
                this._shape.graphics.moveTo(0, 0);
                this._shape.graphics.lineStyle(0, 16777215, 0);
                this._shape.graphics.beginFill(10066329, 0.5);
                this._shape.graphics.lineTo(255, 0);
                this._shape.graphics.lineTo(255, 23);
                this._shape.graphics.lineTo(0, 23);
                this._shape.graphics.endFill();
                this._shape.cacheAsBitmap = true;
            }
            return;
        }

        public clearBgColor(): void
        {
            this._isDraw = false;
            this._shape.graphics.clear();
            return;
        }

        /* internal */ /* var */_txtTf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_campTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_entity: IEntity;

        /* internal */ /* var */_shape: Object /* flash.display.Shape */;

        /* internal */ /* var */_isDraw: Boolean=false;
    }
